<html>
<head><meta charset="utf-8"><title>change config option in release mode · t-compiler · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/index.html">t-compiler</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/change.20config.20option.20in.20release.20mode.html">change config option in release mode</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="228658963"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/change%20config%20option%20in%20release%20mode/near/228658963" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/change.20config.20option.20in.20release.20mode.html#228658963">(Mar 03 2021 at 20:08)</a>:</h4>
<p>if you want a config option to have a different default value in release mode, should one change the parse function that's used?</p>



<a name="228659004"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/change%20config%20option%20in%20release%20mode/near/228659004" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/change.20config.20option.20in.20release.20mode.html#228659004">(Mar 03 2021 at 20:08)</a>:</h4>
<p>like</p>



<a name="228659006"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/change%20config%20option%20in%20release%20mode/near/228659006" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/change.20config.20option.20in.20release.20mode.html#228659006">(Mar 03 2021 at 20:08)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/blob/247337f4093b3177760a25a11b3e1f130882c37c/compiler/rustc_session/src/options.rs#L1000-L1001">https://github.com/rust-lang/rust/blob/247337f4093b3177760a25a11b3e1f130882c37c/compiler/rustc_session/src/options.rs#L1000-L1001</a></p>



<a name="228659081"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/change%20config%20option%20in%20release%20mode/near/228659081" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/change.20config.20option.20in.20release.20mode.html#228659081">(Mar 03 2021 at 20:08)</a>:</h4>
<p>instead of <code>parse_uint</code> use a different thing</p>



<a name="228659146"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/change%20config%20option%20in%20release%20mode/near/228659146" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/change.20config.20option.20in.20release.20mode.html#228659146">(Mar 03 2021 at 20:09)</a>:</h4>
<p>I was expecting to find some example or some other option that works like that but wasn't able</p>



<a name="228659468"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/change%20config%20option%20in%20release%20mode/near/228659468" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/change.20config.20option.20in.20release.20mode.html#228659468">(Mar 03 2021 at 20:11)</a>:</h4>
<p>"release mode" is a cargo concept really</p>



<a name="228659496"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/change%20config%20option%20in%20release%20mode/near/228659496" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/change.20config.20option.20in.20release.20mode.html#228659496">(Mar 03 2021 at 20:11)</a>:</h4>
<p>there's no <code>--release</code> for the rust compiler itself</p>



<a name="228659633"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/change%20config%20option%20in%20release%20mode/near/228659633" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/change.20config.20option.20in.20release.20mode.html#228659633">(Mar 03 2021 at 20:12)</a>:</h4>
<p>yeah, I meant with the "release" kind of optimizations on</p>



<a name="228659778"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/change%20config%20option%20in%20release%20mode/near/228659778" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/change.20config.20option.20in.20release.20mode.html#228659778">(Mar 03 2021 at 20:13)</a>:</h4>
<p>oh, like enable it with <code>-O2</code>? I'm not sure how to do that but it sounds reasonable</p>



<a name="228659893"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/change%20config%20option%20in%20release%20mode/near/228659893" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/change.20config.20option.20in.20release.20mode.html#228659893">(Mar 03 2021 at 20:13)</a>:</h4>
<p>probably <code>tcx.sess.opts.optimize != OptLevel::No</code></p>



<a name="228659950"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/change%20config%20option%20in%20release%20mode/near/228659950" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/change.20config.20option.20in.20release.20mode.html#228659950">(Mar 03 2021 at 20:14)</a>:</h4>
<p>anyway, I guess I'd need to roll my own parse and do that</p>



<a name="228661187"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/change%20config%20option%20in%20release%20mode/near/228661187" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/change.20config.20option.20in.20release.20mode.html#228661187">(Mar 03 2021 at 20:21)</a>:</h4>
<p>wait, I don't think you should do this in the parsing step</p>



<a name="228661219"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/change%20config%20option%20in%20release%20mode/near/228661219" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/change.20config.20option.20in.20release.20mode.html#228661219">(Mar 03 2021 at 20:21)</a>:</h4>
<p>isn't there a later point where we walk over the config and change its defaults based on other settings?</p>



<a name="228661235"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/change%20config%20option%20in%20release%20mode/near/228661235" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/change.20config.20option.20in.20release.20mode.html#228661235">(Mar 03 2021 at 20:21)</a>:</h4>
<p>/me looks</p>



<a name="228661415"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/change%20config%20option%20in%20release%20mode/near/228661415" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/change.20config.20option.20in.20release.20mode.html#228661415">(Mar 03 2021 at 20:23)</a>:</h4>
<p>Usually it's just a function on session that evaluates several different options and returns the canonical value.</p>



<a name="228661516"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/change%20config%20option%20in%20release%20mode/near/228661516" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/change.20config.20option.20in.20release.20mode.html#228661516">(Mar 03 2021 at 20:23)</a>:</h4>
<p>Oh that's right! <span class="user-mention" data-user-id="116266">@Santiago Pastorino</span> , keep the field in <code>tcx.sess.opts</code> simple, but make a method on session that figures out the right value</p>



<a name="228661649"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/change%20config%20option%20in%20release%20mode/near/228661649" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/change.20config.20option.20in.20release.20mode.html#228661649">(Mar 03 2021 at 20:24)</a>:</h4>
<p><span aria-label="+1" class="emoji emoji-1f44d" role="img" title="+1">:+1:</span></p>



<a name="228661705"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/change%20config%20option%20in%20release%20mode/near/228661705" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/change.20config.20option.20in.20release.20mode.html#228661705">(Mar 03 2021 at 20:24)</a>:</h4>
<p>e.g. look at this <code>fn verify_llvm_ir()</code> method:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="w">    </span><span class="k">pub</span><span class="w"> </span><span class="k">fn</span> <span class="nf">verify_llvm_ir</span><span class="p">(</span><span class="o">&amp;</span><span class="bp">self</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="kt">bool</span> <span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="bp">self</span><span class="p">.</span><span class="n">opts</span><span class="p">.</span><span class="n">debugging_opts</span><span class="p">.</span><span class="n">verify_llvm_ir</span><span class="w"> </span><span class="o">||</span><span class="w"> </span><span class="fm">option_env!</span><span class="p">(</span><span class="s">"RUSTC_VERIFY_LLVM_IR"</span><span class="p">).</span><span class="n">is_some</span><span class="p">()</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="228663426"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/change%20config%20option%20in%20release%20mode/near/228663426" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/change.20config.20option.20in.20release.20mode.html#228663426">(Mar 03 2021 at 20:35)</a>:</h4>
<p><span class="user-mention" data-user-id="116083">@pnkfelix</span> right</p>



<a name="228663523"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/change%20config%20option%20in%20release%20mode/near/228663523" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/change.20config.20option.20in.20release.20mode.html#228663523">(Mar 03 2021 at 20:36)</a>:</h4>
<p>the thing that bothers me a bit is that users of the code can just bypass this methods and go directly to opts and get the inner value</p>



<a name="228664125"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/change%20config%20option%20in%20release%20mode/near/228664125" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/change.20config.20option.20in.20release.20mode.html#228664125">(Mar 03 2021 at 20:40)</a>:</h4>
<p>yeah it's unfortunate, if possible make them private</p>



<a name="228664145"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/change%20config%20option%20in%20release%20mode/near/228664145" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/change.20config.20option.20in.20release.20mode.html#228664145">(Mar 03 2021 at 20:40)</a>:</h4>
<p>but we don't have great answer</p>



<a name="228664201"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/change%20config%20option%20in%20release%20mode/near/228664201" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/change.20config.20option.20in.20release.20mode.html#228664201">(Mar 03 2021 at 20:40)</a>:</h4>
<p>in the future we should likely have some kind of wrapper type or something, but seems hard to get right</p>



<a name="228664303"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/change%20config%20option%20in%20release%20mode/near/228664303" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/change.20config.20option.20in.20release.20mode.html#228664303">(Mar 03 2021 at 20:41)</a>:</h4>
<p>yeah but I think the macro makes it public</p>



<a name="228664311"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/change%20config%20option%20in%20release%20mode/near/228664311" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/change.20config.20option.20in.20release.20mode.html#228664311">(Mar 03 2021 at 20:41)</a>:</h4>
<p>anyway good to know :)</p>



<a name="228664377"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/change%20config%20option%20in%20release%20mode/near/228664377" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/change.20config.20option.20in.20release.20mode.html#228664377">(Mar 03 2021 at 20:41)</a>:</h4>
<p>another thing, is there a way to know if this was set by the user or just getting the default value?</p>



<a name="228664510"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/change%20config%20option%20in%20release%20mode/near/228664510" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/change.20config.20option.20in.20release.20mode.html#228664510">(Mar 03 2021 at 20:42)</a>:</h4>
<p>I'd like to say, if the user didn't provide a value for this option and we're in "release" mode set this value, otherwise use whatever is in the opt</p>



<a name="228664589"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/change%20config%20option%20in%20release%20mode/near/228664589" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/change.20config.20option.20in.20release.20mode.html#228664589">(Mar 03 2021 at 20:43)</a>:</h4>
<p>I don't want to just change the provided value if we are in "release" mode because the user provided a specific value for a reason</p>



<a name="228664631"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/change%20config%20option%20in%20release%20mode/near/228664631" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tm <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/change.20config.20option.20in.20release.20mode.html#228664631">(Mar 03 2021 at 20:43)</a>:</h4>
<p>you could use Option and parse_opt_*</p>



<a name="228664742"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/change%20config%20option%20in%20release%20mode/near/228664742" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/change.20config.20option.20in.20release.20mode.html#228664742">(Mar 03 2021 at 20:44)</a>:</h4>
<p>oh right :facepalm:</p>



<a name="228664753"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/change%20config%20option%20in%20release%20mode/near/228664753" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/change.20config.20option.20in.20release.20mode.html#228664753">(Mar 03 2021 at 20:44)</a>:</h4>
<p>yeah it makes sense</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>